const { Tab } = require('../../assets/libs/zanui/index');

var app = getApp();
Page(Object.assign({}, Tab, {
  data: {
    userInfo: '',
		cdnUrl: '',
		/* 自定义导航栏参数 */
		loading: false,
		color: '#FFFFFF',
		background: '#02B3BA',
		show: true,
		animated: false,
		back: false,
		title: "首页",
		
		/* 自定义tabbar */
		list: [
			{
			    "pagePath": "/page/index/index",
			    "iconPath": "/assets/images/tabbar/index.png",
			    "selectedIconPath": "/assets/images/tabbar/index-hl.png",
			    "text": "首页"
			},
			{
			    "pagePath": "/page/discover/index",
			    "iconPath": "/assets/images/tabbar/addon.png",
			    "selectedIconPath": "/assets/images/tabbar/addon-hl.png",
			    "text": "发现"
			},
			{
			    "pagePath": "/page/my/index",
			    "iconPath": "/assets/images/tabbar/my.png",
			    "selectedIconPath": "/assets/images/tabbar/my-hl.png",
			    "text": "我的"
			}
		],
		currentTab: 0,
	  images:[],
  },
  tabChange(e) {
  	wx.reLaunch({
  	  url: e.detail.item.pagePath
  	})
  },
  onLoad: function () {
    var that = this;
		that.setData({
			cdnUrl: app.cdnUrl,
      userInfo: app.globalData.userInfo
		});
		wx.getUserProfile({
		  lang:'zh',
		  desc:'授权用户信息',
		  success:function(res){
				console.log(res);
				app.login(res.userInfo,function () {
					that.setData({ userInfo: app.globalData.userInfo });
				});
		  },
		});
  },
	onShow: function (){
		var that = this;
		if (!app.globalData.userInfo) {
		  app.check(that);
		}
		that.setData({
			images: [
				that.data.cdnUrl+"/uploads/20210511/cf8c74bcb47b98a4ba2e39a6fe910bbe.png",
				that.data.cdnUrl+"/uploads/20210511/d75209f44050933e7f7f8a2284b38f2a.png",
				that.data.cdnUrl+"/uploads/20210511/6a254cd52ee17ad19e1fccffd0b2752f.png",
				that.data.cdnUrl+"/uploads/20210511/9920f538c2b0187685ca88744f69665d.png",
				that.data.cdnUrl+"/uploads/20210511/9920f538c2b0187685ca88744f69665d.png",
			]
		})
	},
  onShareAppMessage: function () {
    return {
      title: '',
      desc: '',
      path: '/page/index/index'
    };
  },
  /* 拨打客服电话*/
  makePhone: function(){
    wx.makePhoneCall({
      phoneNumber: app.globalData.config.customer_service_mobile
    })
  }
}));
